package com.example.easycheck;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.easycheck.utils.AlertDialogManager;
import com.example.easycheck.utils.ConnectionDetector;

public class FirstActivity extends Activity {
	 
    // flag for Internet connection status
    Boolean isInternetPresent = false;
 
    // Connection detector class
    ConnectionDetector cd;
 
    // Alert Dialog Manager
    AlertDialogManager alert = new AlertDialogManager();
 
    // Button
    Button btnCheck;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);
 
        cd = new ConnectionDetector(getApplicationContext());
 
        // Check if Internet present
        isInternetPresent = cd.isConnectingToInternet();
        if (!isInternetPresent) {
            // Internet Connection is not present
            alert.showAlertDialog(FirstActivity.this, "Internet Connection Error",
                    "Please connect to working Internet connection", false);
            Toast.makeText(FirstActivity.this, "No hay internet",
    				Toast.LENGTH_LONG).show();
            return;
        } else {
        	Toast.makeText(FirstActivity.this, "SI hay internet",
    				Toast.LENGTH_LONG).show();
        }
 
        
        // button show on map
        btnCheck = (Button) findViewById(R.id.button1);
 
        /** Button click event for showing the business around you */
        btnCheck.setOnClickListener(new View.OnClickListener() {
 
            @Override
            public void onClick(View arg0) {
                Intent i = new Intent(getApplicationContext(),
                        MainActivity.class);
 
                startActivity(i);
            }
        });
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
 
}